using System;

namespace ServiceUtilities
{
    public class FailureAction
    {
        public static readonly FailureAction None = new FailureAction(RecoverAction.None, 0);
        public static readonly FailureAction RestartNow = new FailureAction(RecoverAction.Restart, 0);
        public static readonly FailureAction RestartFifteenSeconds = new FailureAction(RecoverAction.Restart, new TimeSpan(0, 0, 15));
        public static readonly FailureAction Reboot = new FailureAction(RecoverAction.Reboot, new TimeSpan(0, 0, 0));
        public static readonly FailureAction RunCommand = new FailureAction(RecoverAction.RunCommand, new TimeSpan(0, 0, 0));

        // Default constructor
        public FailureAction()
        {
        }

        // Constructor
        public FailureAction(RecoverAction actionType, int actionDelay)
        {
            Type = actionType;
            Delay = actionDelay;
        }

        public FailureAction(RecoverAction actionType, TimeSpan actionDelay)
        {
            Type = actionType;
            Delay = (int)actionDelay.TotalMilliseconds;
        }

        // Property to set recover action type
        public RecoverAction Type { get; set; }

        // Property to set recover action delay
        public int Delay { get; set; }
    }
}